﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DataCenter_DataBase;

namespace DataCenter.Models.WeiXin
{
    public class WeiXinEvent_unsubscribe:BaseWeiXinEvent
    {
        private ApiDataBase m_Api;
        public WeiXinEvent_unsubscribe(KeaoBase.KeaoXmlHelper XmlHelper) : base(XmlHelper)
        {
            m_Api = new ApiDataBase();
        }

        public override string ResponseResult()
        {

            List<tbl_weixin_user> userItems = m_Api._Db.tbl_weixin_user.Where(item => item.openid == this.FromUserName).ToList();
            if (userItems.Count > 0)
            {
                m_Api._Db.tbl_weixin_user.Remove(userItems[0]);
                m_Api._Db.SaveChanges();
            }
            return base.ResponseResult();
        }

    }
}